//
//  GXLinkHeader.m
//  

#import "GXLinkHeader.h"
#import "GXLinkView.h"

@interface GXLinkHeader ()

@property (nonatomic, weak) GXLinkView *linkView;

@end

@implementation GXLinkHeader

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}


#pragma mark - setupUI
- (void)setupUI {
    self.contentView.backgroundColor = kColorButton;
    //
    GXLinkView *linkView = [[GXLinkView alloc] init];
    [self.contentView addSubview:linkView];
    
    [linkView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.bottom.trailing.equalTo(self.contentView).mas_offset(0);
    }];
    
    //
    [self layoutIfNeeded];
    
    self.headerHeight = linkView.maxHeight;
    self.headerWidth = linkView.maxWidth;
    
    //
    self.linkView = linkView;
}


#pragma mark - setter & getter
- (void)setLinkHeaderList:(NSArray<NSString *> *)linkHeaderList {
    _linkHeaderList = linkHeaderList;
    self.linkView.controllerEnum = self.controllerEnum;
    
    self.linkView.titles = linkHeaderList;
    
    if ([self.reuseIdentifier isEqualToString:@"linkPrefixHeaderId"] || [self.reuseIdentifier isEqualToString:@"linkPrefixAnotherHeaderId"]) {
        [self.linkView setWidth:40 forIndex:0];
        [self.linkView setTextAlignment:NSTextAlignmentCenter forIndex:0];
        [self.linkView setTextAlignment:NSTextAlignmentLeft forIndex:1];
    }
    
    _headerHeight = self.linkView.maxHeight;
    _headerWidth = self.linkView.maxWidth;
    
    [self.linkView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.bottom.trailing.equalTo(self.contentView).mas_offset(0);
        make.height.mas_offset(_headerHeight + 12);
        make.width.mas_offset(_headerWidth);
    }];
    [self.contentView layoutIfNeeded];
}









@end
